package com.runjian.rundo.iot.agent.business.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.KafkaTemplate;

import com.runjian.rundo.iot.agent.business.control.executor.DeviceCommandExecutor;
import com.runjian.rundo.iot.agent.business.kafka.KafkaControlConsumer;
import com.runjian.rundo.iot.agent.business.kafka.KafkaSender;
import com.runjian.rundo.iot.agent.business.publisher.impl.KafkaMessagePublisher;

import lombok.Getter;
import lombok.Setter;

/**
 * 业务常量
 *
 * @author CaoQingHua
 */
@Getter
@Setter
@EnableConfigurationProperties(KafkaConfigurationProperties.class)
@Configuration
public class KafkaAutoConfiguration {

    @Bean
    public KafkaControlConsumer kafkaControlConsumer(DeviceCommandExecutor deviceCommandExecutor) {
        return new KafkaControlConsumer(deviceCommandExecutor);
    }

    @Bean
    public KafkaSender kafkaSender(KafkaTemplate<String, String> kafkaTemplate) {
        return new KafkaSender(kafkaTemplate);
    }

    @Bean
    public KafkaMessagePublisher kafkaMessagePublisher(BaseConfigurationProperties baseConfigurationProperties, KafkaSender kafkaSender) {
        return new KafkaMessagePublisher(baseConfigurationProperties, kafkaSender);
    }

}
